import { MockMethod } from "vite-plugin-mock";
import dayjs from "dayjs";
import { clone } from "@pureadmin/utils";

const date = dayjs(new Date()).format("YYYY-MM-DD");

const tableData = [
  {
    date,
    name: "Tom",
    address: "No. 189, Grove St, Los Angeles"
  },
  {
    date,
    name: "Jack",
    address: "No. 189, Grove St, Los Angeles"
  },
  {
    date,
    name: "Dick",
    address: "No. 189, Grove St, Los Angeles"
  },
  {
    date,
    name: "Harry",
    address: "No. 189, Grove St, Los Angeles"
  },
  {
    date,
    name: "Sam",
    address: "No. 189, Grove St, Los Angeles"
  },
  {
    date,
    name: "Lucy",
    address: "No. 189, Grove St, Los Angeles"
  },
  {
    date,
    name: "Mary",
    address: "No. 189, Grove St, Los Angeles"
  },
  {
    date,
    name: "Mike",
    address: "No. 189, Grove St, Los Angeles"
  }
];
const tableDataDrag = clone([...tableData, ...tableData], true).map(
  (item, index) => {
    delete item.address;
    delete item.date;
    return Object.assign(
      {
        id: index + 1,
        date: `${dayjs(new Date()).format("YYYY-MM")}-${index + 1}`
      },
      item
    );
  }
);
// 模拟刷新token接口
export default [
  {
    url: "/getTableData",
    method: "post",
    response: () => {
      return {
        success: true,
        data: { list: [...tableDataDrag], total: 50 }
      };
    }
  }
] as MockMethod[];
